    var longestPalindrome = function (s) {
        var str = ''
        var startIndex = 0
        while (startIndex <= s.length) {
            for (let index = startIndex + 1; index <= s.length; index++) {
                const strc = s.substring(startIndex, index)
                const strome = isPalindrome(strc)
                if (strome !== -1) {
                    if (strome.length > str.length) {
                        str = strome
                    }
                }
            }
            startIndex++
        }
        return str
    };

    var isPalindrome = s => {
        let minKey = s.length / 2
        let floor = String(minKey).indexOf(".") + 1
        var rightLen = parseInt(minKey)
        for (let i = rightLen - 1; i >= 0; i--) {
            if (s[i] !== s[s.length - i - 1]) {
                return -1
            }
        }
        return s
    }

    console.log(longestPalindrome("ksbabsk"))
    console.log(longestPalindrome("babad"))
    console.log(longestPalindrome("cbbd"))
    console.log(longestPalindrome("ksbbsk"))